@echo off
echo ========================================
echo Ubuntu 22.04 环境配置脚本
echo 安装开发工具和RISC-V工具链
echo ========================================
echo.

echo 启动Ubuntu 22.04...
wsl -d Ubuntu-22.04

echo.
echo 在Ubuntu中运行以下命令：
echo.
echo # 更新系统
echo sudo apt update ^&^& sudo apt upgrade -y
echo.
echo # 安装基础开发工具
echo sudo apt install -y build-essential git python3 qemu-system-misc expect gdb-multiarch
echo.
echo # 安装RISC-V工具链
echo wget https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.07.07/riscv64-elf-ubuntu-20.04-gcc-nightly-2023.07.07-nightly.tar.gz
echo sudo tar -xzf riscv64-elf-ubuntu-20.04-gcc-nightly-2023.07.07-nightly.tar.gz -C /opt/
echo echo 'export PATH="/opt/riscv/bin:$PATH"' ^>^> ~/.bashrc
echo source ~/.bashrc
echo.
echo # 验证安装
echo riscv64-unknown-elf-gcc --version
echo qemu-system-riscv64 --version
echo.
echo # 获取xv6参考源码
echo git clone https://github.com/mit-pdos/xv6-riscv.git
echo cd xv6-riscv
echo make qemu
echo.

pause


